home *** CD-ROM | disk | FTP | other *** search
- /*
- File: OpenTptDev.h
-
- Contains: Equates for Open Transport module development
-
- Copyright: © 1993-1995 by Apple Computer, Inc. and Mentat Inc., all rights reserved.
-
- */
-
- #ifndef __OPENTPTDEV__
- #define __OPENTPTDEV__
-
- #ifndef __OPENTRANSPORT__
- #include <OpenTransport.h>
- #endif
- #ifndef _MPS_STREAM_
- #include <mistream.h>
- #endif
-
- /*******************************************************************************
- ** Some typedefs
- ********************************************************************************/
-
- typedef void* (* _CDECL OTAllocMemProcPtr)(size_t);
- typedef void (* _CDECL OTFreeMemProcPtr)(void*);
-
- #define MI_BIG_ENDIAN 1
- #undef MI_LITTLE_ENDIAN
-
- //
- // For static members that need to match pascal functions
- //
- #define _FSDECL static pascal
- #define _FSDEF pascal
- #define _MDEF /* %%% Temporary */
-
- /*******************************************************************************
- ** Time functions
- **
- ** OTGetTimeStamp returns time in "tick" numbers, stored in 64 bits.
- ** This timestamp can be used as a base number for calculating elapsed
- ** time.
- ** OTSubtractTimeStamps returns a pointer to the "result" parameter.
- **
- ** OTGetClockTimeInSecs returns time since Open Transport was initialized
- ** in seconds.
- ********************************************************************************/
-
- typedef UnsignedWide OTTimeStamp;
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- void OTGetTimeStamp(OTTimeStamp*);
- OTTimeStamp* OTSubtractTimeStamps(OTTimeStamp* result, OTTimeStamp* start,
- OTTimeStamp* end);
- UInt32 OTTimeStampInMilliseconds(OTTimeStamp* delta);
- UInt32 OTTimeStampInMicroseconds(OTTimeStamp* delta);
- UInt32 OTElapsedMilliseconds(OTTimeStamp* startTime);
- UInt32 OTElapsedMicroseconds(OTTimeStamp* startTime);
-
- UInt32 OTGetClockTimeInSecs(void);
- UInt32 OTGetTimerTicks(void);
-
- #ifdef __cplusplus
- }
- #endif
-
- /*******************************************************************************
- ** OTLIFO
- **
- ** These are functions to implement a LIFO list that is interrupt-safe. The only
- ** function which is not is OTReverseList. Normally, you create a LIFO list,
- ** populate it at interrupt time, and then use OTLIFOStealList to atomically
- ** remove the list, and OTReverseList to flip the list so that it is a FIFO
- ** list, which tends to be more useful.
- ********************************************************************************/
-
- typedef struct OTLink OTLink;
- typedef struct OTLIFO OTLIFO;
-
- struct OTLink
- {
- OTLink* fNext;
-
- #ifdef __cplusplus
- void Init()
- { fNext = NULL; }
- #endif
- };
-
- #ifdef __cplusplus
- extern "C" {
- #endif
- //
- // This function puts "object" on the listHead, and places the
- // previous value at listHead into the pointer at "object" plus
- // linkOffset.
- //
- void OTEnqueue(void** listHead, void* object, size_t linkOffset);
- //
- // This function returns the head object of the list, and places
- // the pointer at "object" + linkOffset into the listHead
- //
- void* OTDequeue(void** listHead, size_t linkOffset);
- //
- // This function atomically enqueues the link onto the list
- //
- void OTLIFOEnqueue(OTLIFO*, OTLink*);
- //
- // This function atomically dequeues the first element
- // on the list
- //
- OTLink* OTLIFODequeue(OTLIFO* list);
- //
- // This function atomically empties the list and returns a
- // pointer to the first element on the list
- //
- OTLink* OTLIFOStealList(OTLIFO*);
- //
- // This function reverses a list that was stolen by
- // OTLIFOStealList. It is NOT atomic. It returns the
- // new starting list.
- //
- OTLink* OTReverseList(OTLink*);
-
- #ifdef __cplusplus
- }
- #endif
-
- struct OTLIFO
- {
- OTLink* fHead;
-
- #ifdef __cplusplus
- void Init()
- { fHead = NULL; }
-
- void Enqueue(OTLink* link)
- { OTLIFOEnqueue(this, link); }
-
- OTLink* Dequeue()
- { return OTLIFODequeue(this); }
-
- OTLink* StealList()
- { return OTLIFOStealList(this); }
-
- Boolean IsEmpty()
- { return fHead == NULL; }
- #endif
- };
-
- /*******************************************************************************
- ** OTList
- **
- ** An OTList is a non-interrupt-safe list, but has more features than the
- ** OTLIFO list. It is a doubly-linked list that is in a ring configuration.
- ** Therefore, do not attempt to walk the list manually, since there is no
- ** NULL pointer terminating the list, and also be sure to call OTInitList
- ** on the list or the results will be unpleasant.
- ********************************************************************************/
-
- typedef struct OTList OTList;
-
- typedef Boolean (* _CDECL OTListSearchProcPtr)(const void* ref, OTLink* linkToCheck);
-
- #ifdef __cplusplus
- extern "C" {
- #endif
- //
- // Add the link to the list at the front
- //
- void OTAddFirst(OTList*, OTLink*);
- //
- // Add the link to the list at the end
- //
- void OTAddLast(OTList*, OTLink*);
- //
- // Remove the first link from the list
- //
- OTLink* OTRemoveFirst(OTList*);
- //
- // Remove the last link from the list
- //
- OTLink* OTRemoveLast(OTList*);
- //
- // Return the first link from the list
- //
- OTLink* OTGetFirst(OTList*);
- //
- // Return the last link from the list
- //
- OTLink* OTGetLast(OTList*);
- //
- // Return true if the link is present in the list
- //
- Boolean OTIsInList(OTList*, OTLink*);
- //
- // Find a link in the list which matches the search criteria
- // established by the search proc and the refPtr. This is done
- // by calling the search proc, passing it the refPtr and each
- // link in the list, until the search proc returns true.
- // NULL is returned if the search proc never returned true.
- //
- OTLink* OTFindLink(OTList*, OTListSearchProcPtr, const void* refPtr);
- //
- // Remove the specified link from the list, returning true if it was found
- //
- Boolean OTRemoveLink(OTList*, OTLink*);
- //
- // Similar to OTFindLink, but it also removes it from the list.
- //
- OTLink* OTFindAndRemoveLink(OTList*, OTListSearchProcPtr, const void* refPtr);
- //
- // Return the "index"th link in the list
- //
- OTLink* OTGetIndexedLink(OTList*, size_t index);
-
- #ifdef __cplusplus
- }
- #endif
-
- struct OTList
- {
- OTLink* fHead;
-
- #ifdef __cplusplus
- void Init()
- { fHead = NULL; }
-
- Boolean IsEmpty()
- { return fHead == NULL; }
-
- void AddFirst(OTLink* link)
- { OTAddFirst(this, link); }
-
- void AddLast(OTLink* link)
- { OTAddLast(this, link); }
-
- OTLink* GetFirst()
- { return OTGetFirst(this); }
-
- OTLink* GetLast()
- { return OTGetLast(this); }
-
- OTLink* RemoveFirst()
- { return OTRemoveFirst(this); }
-
- OTLink* RemoveLast()
- { return OTRemoveLast(this); }
-
- Boolean IsInList(OTLink* link)
- { return OTIsInList(this, link); }
-
- OTLink* FindLink(OTListSearchProcPtr proc, const void* ref)
- { return OTFindLink(this, proc, ref); }
-
- Boolean RemoveLink(OTLink* link)
- { return OTRemoveLink(this, link); }
-
- OTLink* RemoveLink(OTListSearchProcPtr proc, const void* ref)
- { return OTFindAndRemoveLink(this, proc, ref); }
-
- OTLink* GetIndexedLink(size_t index)
- { return OTGetIndexedLink(this, index); }
- #endif
- };
-
- #define OTGetLinkObject(link, struc, field) \
- ((struc*)((char*)(link) - offsetof(struc, field)))
-
- /*******************************************************************************
- ** Hash List
- ********************************************************************************/
-
- typedef struct OTHashList OTHashList;
-
- typedef UInt32 (* _CDECL OTHashProcPtr)(OTLink* linkToHash);
- typedef Boolean (* _CDECL OTHashSearchProcPtr)(const void* ref, OTLink* linkToCheck);
-
- #ifdef __cplusplus
- extern "C" {
- #endif
- //
- // Return the number of bytes of memory needed to create a hash list
- // of at least "numEntries" entries.
- //
- size_t OTCalculateHashListMemoryNeeds(size_t numEntries);
- //
- // Create an OTHashList from "memory". Return an error if it
- // couldn't be done.
- //
- OTResult OTInitHashList(void* memory, size_t numBytes, OTHashProcPtr);
- void OTAddToHashList(OTHashList*, OTLink*);
- Boolean OTRemoveLinkFromHashList(OTHashList*, OTLink*);
- Boolean OTIsInHashList(OTHashList*, OTLink*);
- OTLink* OTFindInHashList(OTHashList*, OTHashSearchProcPtr proc,
- const void* refPtr, UInt32 hashValue);
- OTLink* OTRemoveFromHashList(OTHashList*, OTHashSearchProcPtr proc,
- const void* refPtr, UInt32 hashValue);
-
- #ifdef __cplusplus
- }
- #endif
-
- struct OTHashList
- {
- OTHashProcPtr fHashProc;
- size_t fHashTableSize;
- OTLink** fHashBuckets;
-
- #ifdef __cplusplus
- void Add(OTLink* toAdd)
- { OTAddToHashList(this, toAdd); }
-
- Boolean RemoveLink(OTLink* toRemove)
- { return OTRemoveLinkFromHashList(this, toRemove); }
-
- OTLink* Remove(OTHashSearchProcPtr proc,
- const void* refPtr, UInt32 hashValue)
- { return OTRemoveFromHashList(this, proc, refPtr, hashValue); }
-
- Boolean IsInList(OTLink* toFind)
- { return OTIsInHashList(this, toFind); }
-
- OTLink* FindLink(OTHashSearchProcPtr proc, const void* refPtr,
- UInt32 hash)
- { return OTFindInHashList(this, proc, refPtr, hash); }
- #endif
- };
-
- /*******************************************************************************
- ** Random functions
- ********************************************************************************/
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- UInt32 OTGetRandomSeed();
- UInt32 OTGetRandomNumber(UInt32* seed, UInt32 lo, UInt32 hi);
-
- #ifdef __cplusplus
- }
- #endif
-
- /*******************************************************************************
- ** Bitmap Functions
- ********************************************************************************/
-
- #ifdef __cplusplus
- extern "C" {
- #endif
- //
- // Set the first clear bit in "bitMap", starting with bit "startBit",
- // giving up after "numBits". Returns the bit # that was set, or
- // a kOTNotFoundErr if there was no clear bit available
- //
- OTResult OTSetFirstClearBit(UInt8* bitMap, size_t startBit, size_t numBits);
- //
- // Standard clear, set and test bit functions
- //
- Boolean OTClearBit(UInt8* bitMap, size_t bitNo);
- Boolean OTSetBit(UInt8* bitMap, size_t bitNo);
- Boolean OTTestBit(UInt8* bitMap, size_t bitNo);
-
- #ifdef __cplusplus
- }
- #endif
-
-
- /*******************************************************************************
- ** Memory functions
- ********************************************************************************/
-
- typedef void* OTVoidPtr;
- typedef OTVoidPtr (*_CDECL OTAllocateProcPtr)(size_t);
- typedef void (*_CDECL OTFreeProcPtr)(void*);
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- void OTMemcpy(void* dest, const void* src, size_t nBytes);
- Boolean OTMemcmp(const void* mem1, const void* mem2, size_t nBytes);
- void OTMemmove(void* dest, const void* src, size_t nBytes);
- void OTMemzero(void* dest, size_t nBytes);
- void OTMemset(void* dest, UInt8 toSet, size_t nBytes);
- size_t OTStrLength(const char*);
- void OTStrCopy(char*, const char*);
- void OTStrCat(char*, const char*);
- Boolean OTStrEqual(const char*, const char*);
-
- #ifdef __cplusplus
- }
- #endif
-
- /*******************************************************************************
- ** OTBuffer
- **
- ** This is the structure that is obtained when reading messages from the
- ** streamhead. When you are done with it, you must call the
- ** OTReleaseBuffer function.
- ********************************************************************************/
-
- typedef struct OTBuffer OTBuffer;
-
- struct OTBuffer
- {
- OTLink fLink; // b_next & b_prev
- OTLink fLink2;
- OTBuffer* fNext; // b_cont
- UInt8* fData; // b_rptr
- size_t fLen; // b_wptr
- void* fSave; // b_datap
- UInt8 fBand; // b_band
- UInt8 fType; // b_pad1
- UInt8 fFlags; // b_flag
- UInt8 fPad1;
- };
-
-
- /*******************************************************************************
- ** XmitRecord Class
- **
- ** This class is used when sending "write"-type commands, where we need
- ** information to be able to complete a write to the client when it is
- ** finished.
- ********************************************************************************/
-
- struct XmitRecord
- {
- OTLink fLink;
- void* provider;
- void* dataBuf;
- size_t dataLen;
- SInt16 ackCount;
- };
-
- /*******************************************************************************
- ** Miscellaneous functions
- ********************************************************************************/
-
- #ifdef __cplusplus
- extern "C" {
- #endif
- //
- // Return true if we are at interrupt level
- //
- Boolean OTIsAtInterruptLevel(void);
- //
- // Return true if we are currently at either system task time, or we
- // are running a deferred task procedure from system task time.
- //
- Boolean OTCanLoadLibraries(void);
- void OTEnterCriticalSection(void);
- void OTLeaveCriticalSection(void);
-
- #ifdef __cplusplus
- }
- #endif
-
- /*******************************************************************************
- ** Port ref functions
- ********************************************************************************/
-
- /* -------------------------------------------------------------------------
- Port state change requests
- ------------------------------------------------------------------------- */
-
- enum
- {
- kOTDisablePort = 1, // No new streams
- kOTClosePort = 2, // Force closure of all port clients
- kOTEnablePort = 3 // Undo the 2 above
- };
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- pascal OTPortRef OTSetDeviceTypeInPortRef(OTPortRef ref, UInt16 devType);
- pascal OTPortRef OTSetBusTypeInPortRef(OTPortRef ref, UInt8 busType);
-
- pascal Boolean OTMakePortName(char* buffer, const char* moduleName,
- OTPortRef);
-
- #ifdef __cplusplus
- }
- #endif
-
- /*******************************************************************************
- ** Some defines
- ********************************************************************************/
-
- /* -------------------------------------------------------------------------
- Signals that are generated by a stream
- ------------------------------------------------------------------------- */
-
- enum
- {
- SIGHUP = 1,
- SIGURG = 16,
- SIGPOLL = 30
- };
-
- /* -------------------------------------------------------------------------
- IOCtls used by OpenTransport
- ------------------------------------------------------------------------- */
-
- typedef int OTNotifyType;
-
- enum
- {
- kOTNotifyAllModules = 0, kOTNotifyInterestedModules = 1,
- kOTNotifyControlModules = 2
- };
-
- struct OTIOCtlNotifyInfo
- {
- OTEventCode fCode; // Event Code
- void* fCookie; // Cookie associated with it
- UInt32 fNotifyType;// Who to notify
- };
-
- typedef struct OTIoctlNotifyInfo OTIoctlNotifyInfo;
-
- enum
- {
- I_OTNotifyAllClients = MIOC_CMD(MIOC_OT, 50),
- I_OTSetPowerLevel = MIOC_CMD(MIOC_OT, 51)
- };
-
- /* -------------------------------------------------------------------------
- Some equates for kPROTOCOLEVENTs that normal clients don't need to
- know.
- ------------------------------------------------------------------------- */
-
- enum
- {
- kHiPriProtocolEvent = 0x08000000 /* Bit to be a high-priority event */
- };
-
- #define IsHiPriProtocolEvent(x) (((x) & 0xf8000000) == (kPROTOCOLEVENT | kHiPriProtocolEvent))
- #define StripProtocolEvent(x) ((x) & 0xf0ffffff)
- //
- // Use this template to define your preferences if you use
- // the TStreamGroup and TStreamFamily infrastructure
- //
- #define OTPreferencesFields(num) \
- UInt16 fVersion; \
- UInt16 fNumPrefs; \
- OTPortRef fPort; \
- OTLink fLink; \
- void* fPrefs[num]
- //
- // This template is used to define the first set
- // of fields in each individual preference array
- //
- #define OTPreferenceFields \
- UInt16 fVersion; \
- UInt16 fSize
-
- //
- // Define to tell infrastructure you want the main preference
- // structure instead of a substructure.
- //
- enum
- {
- kOTPrefStructureCode = (UInt32)-1L
- };
-
- /*******************************************************************************
- ** Atomic Operations
- **
- ** The Bit operations return the previous value of the bit (0 or non-zero).
- ** The memory pointed to must be a single byte and only bits 0 through 7 are
- ** valid. Bit 0 corresponds to a mask of 0x01, and Bit 7 to a mask of 0x80.
- ********************************************************************************/
-
- typedef UInt8 OTLock;
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if GENERATING68K
-
- #pragma parameter __D0 OTAtomicSetBit(__A0, __D0)
- Boolean OTAtomicSetBit(UInt8*, size_t) =
- {
- 0x01d0, 0x56c0, /* bset.b d0,(a0); sne d0 */
- 0x7201, 0xc081 /* moveq #1,d1; and.l d1,d0 */
- };
-
- #pragma parameter __D0 OTAtomicClearBit(__A0, __D0)
- Boolean OTAtomicClearBit(UInt8*, size_t) =
- {
- 0x0190, 0x56c0, /* bclr.b d0,(a0); sne d0 */
- 0x7201, 0xc081 /* moveq #1,d1; and.l d1,d0 */
- };
-
- #pragma parameter __D0 OTAtomicTestBit(__A0, __D0)
- Boolean OTAtomicTestBit(UInt8*, size_t) =
- {
- 0x0110, 0x56c0, /* btst.b d0,(a0); sne d0 */
- 0x7201, 0xc081 /* moveq #1,d1; and.l d1,d0 */
- };
-
- #pragma parameter __D0 OTCompareAndSwapPtr(__D0, __D1, __A0)
- Boolean OTCompareAndSwapPtr(void*, void*, void**) =
- {
- 0x0ed0, 0x0040, /* cas.l d0,d1,(a0) */
- 0x57c0, /* seq d0 */
- 0x7201, 0xc081 /* moveq #1,d1; and.l d1,d0 */
- };
-
- #pragma parameter __D0 OTCompareAndSwap32(__D0, __D1, __A0)
- Boolean OTCompareAndSwap32(UInt32, UInt32, UInt32*) =
- {
- 0x0ed0, 0x0040, /* cas.l d0,d1,(a0) */
- 0x57c0, /* seq d0 */
- 0x7201, 0xc081 /* moveq #1,d1; and.l d1,d0 */
- };
-
- #pragma parameter __D0 OTCompareAndSwap16(__D0, __D1, __A0)
- Boolean OTCompareAndSwap16(UInt16, UInt16, UInt16*) =
- {
- 0x0cd0, 0x0040, /* cas.w d0,d1,(a0) */
- 0x57c0, /* seq d0 */
- 0x7201, 0xc081 /* moveq #1,d1; and.l d1,d0 */
- };
-
- #pragma parameter __D0 OTCompareAndSwap8(__D0, __D1, __A0)
- Boolean OTCompareAndSwap8(UInt8, UInt8, UInt8*) =
- {
- 0x0ad0, 0x0040, /* cas.b d0,d1,(a0) */
- 0x57c0, /* seq d0 */
- 0x7201, 0xc081 /* moveq #1,d1; and.l d1,d0 */
- };
-
- #elif GENERATINGPOWERPC
-
- Boolean OTAtomicSetBit(UInt8*, size_t);
- Boolean OTAtomicClearBit(UInt8*, size_t);
- Boolean OTAtomicTestBit(UInt8*, size_t);
- //
- // WARNING! void* and UInt32 locations MUST be on 4-byte boundaries.
- // UInt16 locations must not cross a 4-byte boundary.
- //
- Boolean OTCompareAndSwapPtr(void* oldValue, void* newValue, void** location);
- Boolean OTCompareAndSwap32(UInt32 oldValue, UInt32 newValue, UInt32* location);
- Boolean OTCompareAndSwap16(UInt16 oldValue, UInt16 newValue, UInt16* location);
- Boolean OTCompareAndSwap8(UInt8 oldValue, UInt8 newValue, UInt8* location);
-
- #endif
- //
- // WARNING! UInt32 locations MUST be on 4-byte boundaries.
- // UInt16 locations must not cross a 4-byte boundary.
- //
- SInt32 OTAtomicAdd32(SInt32, SInt32*);
- SInt16 OTAtomicAdd16(SInt16, SInt16*);
- SInt8 OTAtomicAdd8(SInt8, SInt8*);
-
- Boolean OTAcquireLock(OTLock*);
-
- #define OTClearLock(lockPtr) *(lockPtr) = 0
- #define OTAcquireLock(lockPtr) (OTAtomicSetBit(lockPtr, 0) == 0)
-
- #ifdef __cplusplus
- }
- #endif
-
- /*******************************************************************************
- ** Functions to convert xti/mac errors to OSStatus'
- ********************************************************************************/
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- pascal OSStatus OTConvertError(OTXTIErr xtiErr, OTUnixErr macErr);
-
- #ifdef __cplusplus
- }
- #endif
-
- #ifdef __cplusplus
- //
- // Macro for Speed
- //
- inline OSStatus OTDoConvertError(long xtiErr, long macErr)
- {
- return xtiErr == 0 ? kOTNoError : OTConvertError((OTXTIErr)xtiErr, (OTUnixErr)macErr);
- }
-
- #else
-
- #define OTDoConvertError(xtiErr, macErr) \
- ((xtiErr) == 0 ? kOTNoError : OTConvertError((OTXTIErr)(xtiErr), (OTUnixErr)(macErr)))
-
- #endif
-
- /*******************************************************************************
- ** Some efficient implementations of BigEndian and LittleEndian words
- ********************************************************************************/
-
- #if MI_BIG_ENDIAN
- //
- // Since Open Transport is 68020 and better only, we don't have to
- // worry about alignment problems.
- //
- #define GetBigEndian16At(ptr) (*(UInt16*)(ptr))
- #define GetBigEndian32At(ptr) (*(UInt32*)(ptr))
- #define SetBigEndian16At(ptr, val) { *(UInt16*)(ptr) = (UInt16)(val); }
- #define SetBigEndian32At(ptr, val) { *(UInt32*)(ptr) = (UInt32)(val); }
-
- #else
-
- #define GetBigEndian16At(ptr) \
- ((Uint16)(((((UInt8*)ptr)[0]) << 8) + ((UInt8*)ptr)[1]))
-
- #define GetBigEndian32At(ptr) \
- ((UInt32)(((((UInt8*)ptr)[0]) << 24) + \
- (((UInt8*)ptr)[1] << 16) + \
- (((UInt8*)ptr)[2] << 8) + \
- ((UInt8*)ptr)[3]))
-
- #define SetBigEndian16At(ptr, val) \
- { \
- ((UInt8*)ptr)[0] = (UInt8)(val >> 8); \
- ((UInt8*)ptr)[1] = (UInt8)(val); \
- }
-
- #define SetBigEndian32At(ptr, val) \
- { \
- ((UInt8*)ptr)[0] = (UInt8)(val >> 24); \
- ((UInt8*)ptr)[1] = (UInt8)(val >> 16); \
- ((UInt8*)ptr)[2] = (UInt8)(val >> 8); \
- ((UInt8*)ptr)[3] = (UInt8)(val); \
- }
-
- #endif
-
- #if MI_LITTLE_ENDIAN
-
- #define GetLittleEndian16At(ptr) (*(UInt16*)(ptr))
- #define GetLittleEndian32At(ptr) (*(UInt32*)(ptr))
- #define SetLittleEndian16At(ptr, val) { *(UInt16*)(ptr) = (UInt16)(val); }
- #define SetLittleEndian32At(ptr, val) { *(UInt32*)(ptr) = (UInt32)(val); }
-
- #else
-
- #define GetLittleEndian16At(ptr) \
- ((Uint16)(((((UInt8*)ptr)[1]) << 8) + ((UInt8*)ptr)[0]))
-
- #define GetLittleEndian32At(ptr) \
- ((UInt32)(((((UInt8*)ptr)[3]) << 24) + \
- (((UInt8*)ptr)[2] << 16) + \
- (((UInt8*)ptr)[1] << 8) + \
- ((UInt8*)ptr)[0]))
-
- #define SetLittleEndian16At(ptr, val) \
- { \
- ((UInt8*)ptr)[1] = (UInt8)(val >> 8); \
- ((UInt8*)ptr)[0] = (UInt8)(val); \
- }
-
- #define SetLittleEndian32At(ptr, val) \
- { \
- ((UInt8*)ptr)[3] = (UInt8)(val >> 24); \
- ((UInt8*)ptr)[2] = (UInt8)(val >> 16); \
- ((UInt8*)ptr)[1] = (UInt8)(val >> 8); \
- ((UInt8*)ptr)[0] = (UInt8)(val); \
- }
-
- #endif
-
- #ifdef __cplusplus
-
- /* -------------------------------------------------------------------------
- TOTBaseObject
-
- This is the base class for Open Transport objects that DO NOT need to
- be 68K aligned.
- ------------------------------------------------------------------------- */
-
- #if USESINGLEOBJECT
- class TOTBaseObject : public SingleObject
- #else
- class TOTBaseObject
- #endif
- {
- EXTRA_VTABLE_SLOT
-
- public:
- _CT TOTBaseObject() {};
- virtual _DT TOTBaseObject();
-
- private:
- _CT TOTBaseObject(const TOTBaseObject&);
- void operator=(const TOTBaseObject&);
- };
-
- #if GENERATINGPOWERPC
- #pragma options align=mac68k
- #endif
-
- /* -------------------------------------------------------------------------
- TOTAlignedObject
-
- This is the base class for Open Transport objects that DO need to
- be 68K aligned.
- ------------------------------------------------------------------------- */
-
- #if USESINGLEOBJECT
- class TOTAlignedObject : public SingleObject
- #else
- class TOTAlignedObject
- #endif
- {
- EXTRA_VTABLE_SLOT
-
- public:
- _CT TOTAlignedObject() {};
- virtual _DT TOTAlignedObject();
-
- private:
- _CT TOTAlignedObject(const TOTAlignedObject&);
- void operator=(const TOTAlignedObject&);
- };
-
- #if GENERATINGPOWERPC
- #pragma options align=reset
- #endif
-
- #endif
-
- #endif /* __OPENTPTDEV__ */
-